#include <bits/stdc++.h>
#define s first
#define cnt second
using namespace std;
typedef long long ll;
unordered_map<string,ll>a;
string s;
ll n,k,i,ans;
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
while(cin>>n>>k)
{
while(n--)cin>>s,a[s]++;
ans=0;
for(auto it=a.begin();it!=a.end();it++)
{
for(auto it2=a.begin();it2!=a.end();it2++)
{
if(it==it2)continue;
for(i=0;i<k;i++)
{
if(it->s[i]==it2->s[i])s[i]=it->s[i];
else if((it->s[i]=='S'&&it2->s[i]=='T')||(it->s[i]=='T'&&it2->s[i]=='S'))s[i]='E';
else if((it->s[i]=='S'&&it2->s[i]=='E')||(it->s[i]=='E'&&it2->s[i]=='S'))s[i]='T';
else if((it->s[i]=='E'&&it2->s[i]=='T')||(it->s[i]=='T'&&it2->s[i]=='E'))s[i]='S';
}
auto it3=a.find(s);
if(it3!=a.end()&&it3!=it&&it3!=it2)ans+=it->cnt*it2->cnt*it3->cnt;
}
}
cout<<ans/6<<'\n';
a.clear();
}
return 0;
}
540A - Combination Lock | 1553C - Penalty |
1474E - What Is It | 1335B - Construct the String |
1004B - Sonya and Exhibition | 1397A - Juggling Letters |
985C - Liebig's Barrels | 115A - Party |
746B - Decoding | 1424G - Years |
1663A - Who Tested | 1073B - Vasya and Books |
195B - After Training | 455A - Boredom |
1099A - Snowball | 1651D - Nearest Excluded Points |
599A - Patrick and Shopping | 237A - Free Cash |
1615B - And It's Non-Zero | 1619E - MEX and Increments |
34B - Sale | 1436A - Reorder |
1363C - Game On Leaves | 1373C - Pluses and Minuses |
1173B - Nauuo and Chess | 318B - Strings of Power |
1625A - Ancient Civilization | 864A - Fair Game |
1663B - Mike's Sequence | 448A - Rewards |